#pragma once
#include"Vector2.h"

class Camera
{
public:
	Camera()
	{
		timer_shake.set_finished(10000);
		timer_shake.set_func([&]
			{
				is_shaking = false;
				ret_set();
			});
	}
	~Camera() = default;

	const vector2& get_postion()
	{
		return _pos;
	}

	void ret_set()
	{
		_pos = vector2(0, 0);
	}

	void shake(int strength , int interval)
	{
		is_shaking = true;
		shake_strength = strength;

		timer_shake.set_finished(interval);
		timer_shake.ret_start();
	}

	void on_update(int interval)
	{
		timer_shake.on_update(interval);

		if (is_shaking)
		{
			_pos._x = (-50 + rand() % 100) / 50.0f * shake_strength;
			_pos._y = (-50 + rand() % 100) / 50.0f * shake_strength;
		}
	}
private:
	vector2 _pos;

	Timer timer_shake;
	bool is_shaking = false;
	int shake_strength = 0;
};